package com.example.hello1;

import android.app.ListActivity;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import android.util.Log;
import android.widget.ArrayAdapter;
import android.widget.ListAdapter;

import androidx.annotation.NonNull;

import java.util.ArrayList;

public class MylistActivity3 extends ListActivity {
    private static final String Tag = "处理接受数据";
    Handler handler;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
//        setContentView(R.layout.activity_mylist3);

        Log.i(Tag,"开始");
        handler = new Handler(Looper.myLooper()) {
            @Override
            public void handleMessage(@NonNull Message msg) {
                Log.i(Tag,"开始处理");
                if (msg.what == 6) {
                    ArrayList<String> list2 = (ArrayList<String>) msg.obj;
                    Log.i(Tag,"a+"+list2);
                    ListAdapter adapter = new ArrayAdapter<String>(MylistActivity3.this, android.R.layout.simple_list_item_1, list2);
                    setListAdapter(adapter);
                }
                super.handleMessage(msg);

            }
        };
        Mycurrency_thred td = new Mycurrency_thred();
        td.setHadeler(handler);
        Thread t = new Thread(td);
        t.start();//this.run()

//        List<String> list1 = new ArrayList<String>();
//        for(int i=0;i<100;i++)
//        {
//            list1.add("item"+i);
//        }
//        String[] list2={"sdh","rejub","sfsfs"};
//        ListAdapter adapter =new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1,list2);
//        setListAdapter(adapter);

    }
}